package com.qingcheng.controller;

import com.qingcheng.entity.Result;
import com.qingcheng.pojo.order.CategoryReport;
import com.qingcheng.service.CategoryReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/categoryReport")
public class CategoryReportController {

    @Autowired
    private CategoryReportService categoryReportService;
    /**
     * 昨天的数据统计
     * @return
     */
    @GetMapping("/yesterday")
    public Result yesterday(){
//        LocalDate localDate = LocalDate.now().minusDays(1);// 得到昨天的日期
        LocalDate localDate = LocalDate.of(2019, 4, 15);
        List<CategoryReport> categoryReports = categoryReportService.categoryReport(localDate);
        return new Result(200,"统计成功",categoryReports);
    }

    /**
     * 统计一级类目
     * @param date1
     * @param date2
     * @return
     */
    @GetMapping("/category1Count")
    public Result category1Count(String date1, String date2){
        List<Map> list = categoryReportService.category1Count(date1, date2);
        return new Result(200,"查询成功",list);
    }
}